var type = '',shopId = '',interval;
$(document).ready(function(){
    if(global.communityContent){
        $('#user_name').html(global.communityContent.user_name);
        console.log(global.communityContent)
        $('#user').css('display','none');
        $('#main').css('display','none');
        $('#community').css('display','none');
        $('#integral').css('display','none');
        $('#communityHealth').css('display','none');
        $('#communityShop').css('display','none');
        $('#kitchen').css('display','none');
        $('#bookProduct').css('display','none');
        switch (global.communityContent.type) {
            case '0':
                //总后台
                $('#user').css('display','block')
                $('#main').css('display','block')
                break;
            case '1':
                //社区健康商城后台
                $('#communityHealth').css('display','block')
                type = 1
                shopId = global.shop_id
                // getNewEvaluation(shopId)
                break;
            case '2':
                //社区后台
                $('#bookProduct').css('display','block');
                $('#user').css('display','block')
                $('#community').css('display','block')
                $('#integral').css('display','block')
                getAjax(`${global.apiUrl}/Api/Alladmin/community_level`,function(res){
                    // console.log(res)
                    if(res){
                        sessionStorage.setItem('mainType',res.type)
                        sessionStorage.setItem('shopUserId',res.user_id)
                    }
                },{id: global.community_id})
                break;
            case '3':
                //社区商城
                $('#communityShop').css('display','block');
                type = 2
                shopId = global.community_service_shop_id
                break;
            case '4':
                //特膳厨房
                $('#kitchen').css('display','block');
                type = 2
                shopId = global.kitchen_id
                break;
        }
        if(type != ''){
            // console.log(shopId)
            // getNewOrder(shopId,type)
            // clearInterval(interval)
            // interval = setInterval('getNewOrder(shopId,type)',1000 * 60 * 5)
        }
    }
})


// function getNewOrder(shopId,type){
//     getAjax(`${global.apiUrl}/shop_get_one_order_sum`,function(res){
//         console.log(res)
//         if(res && res != 0){
//             sessionStorage.setItem('orderNum',res)
//             switch (type) {
//                 case 1:
//                     $('#communityHealth').find('.orderNum').text('(' + res + ')')
//                     break;
//                 case 2:
//                     $('#communityShop').find('.orderNum').text('(' + res + ')')
//                     break;
//                 case 3:
//                     $('#kitchen').find('.orderNum').text('(' + res + ')')
//                     break;
//             }
//             playSound()
//         }else{
//             switch (type) {
//                 case 1:
//                     $('#communityHealth').find('.orderNum').text('')
//                     break;
//                 case 2:
//                     $('#communityShop').find('.orderNum').text('')
//                     break;
//                 case 3:
//                     $('#kitchen').find('.orderNum').text('')
//                     break;
//             }
//         }
//     },{shop_id: shopId,type: type})
// }

// function playSound(){
//     var borswer = window.navigator.userAgent.toLowerCase();
//     if ( !!window.ActiveXObject || "ActiveXObject" in window ){
//         //IE内核浏览器
//         var OSPlayer = new ActiveXObject("WMPLayer.OCX");
//         OSPlayer.url = 'https://jzj.freei.cc/Uploads/ce/notify.wav';
//         OSPlayer.controls.play();
//     }else{
//         console.log('123')
//         //非IE内核浏览器
//         if ($("body").find("audio").length <= 0 ){
//             var strAudio = "<audio id='audioPlay' src='https://jzj.freei.cc/Uploads/ce/notify.wav' hidden='true'>";
//             $( "body" ).append(strAudio);
//             //浏览器支持 audion
//         }
//         var audio = document.getElementById( "audioPlay" );
//         audio.play();

//     }
// }

// function getNewEvaluation(shopId){
//     getAjax(`${global.apiUrl}/shop_get_no_tell`,function(res){
//         console.log(res)
//         if(res && res != 0){
//             // sessionStorage.setItem('orderNum',res)
//             $('#communityHealth').find('.evaluationNum').text('(' + res + ')')
//             // playSound()
//         }else{
//             $('#communityHealth').find('.evaluationNum').text('')
//         }
//     },{shop_id: shopId})
// }
